package com.demo.bean;

import lombok.Data;

/**
 * API格式封装
 */
public class ApiResponse {
    private int code;
    private String message;
    private Object data;
    private boolean more;

    public ApiResponse(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ApiResponse() {
        this.code = StatusEnum.SUCCESS.getCode();
        this.message = StatusEnum.SUCCESS.getStandardMessage();
    }

    public static ApiResponse ofMessage(int code, String message) {
        return new ApiResponse(code, message, null);
    }

    public static ApiResponse ofSuccess(Object data) {
        return new ApiResponse(StatusEnum.SUCCESS.getCode(), StatusEnum.SUCCESS.getStandardMessage(), data);
    }

    public static ApiResponse ofStatusEnum(StatusEnum StatusEnum) {
        return new ApiResponse(StatusEnum.getCode(), StatusEnum.getStandardMessage(), null);
    }

  
}
